package com.yh.csx.crm.core.enums;

import java.util.EnumSet;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * DutyCategoryEnum class
 * 税分类：0免税、1一般纳税人、2小规模纳税人
 *
 * @author huyalin
 * @date 2019/2/21
 */
public enum TaxesCategoryEnum {
    FREE("0", "免税"),
    GENERAL_TAXPAYER("1", "一般纳税人"),
    SMALL_TAXPAYER("2", "小规模纳税人");

    private String code;
    private String name;

    TaxesCategoryEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    private static final Map<String, TaxesCategoryEnum> valueLookup = new ConcurrentHashMap<>(values().length);

    static {
        for (TaxesCategoryEnum type : EnumSet.allOf(TaxesCategoryEnum.class)) {
            valueLookup.put(type.code, type);
        }
    }

    public static TaxesCategoryEnum resolve(String code) {
        return (code != null ? valueLookup.get(code) : null);
    }

    public static String resolveName(String code) {
        TaxesCategoryEnum category = resolve(code);
        return category == null ? "" : category.getName();
    }
}
